package com.micro.ai.models.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 训练检查点实体类
 * 
 * @author micro-ai
 * @since 0.0.1
 */
@Data
@TableName("training_checkpoints")
@Schema(description = "训练检查点信息")
public class TrainingCheckpoint implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "检查点ID", example = "cp_123456789")
    private String id;

    /**
     * 租户ID
     */
    @Schema(description = "租户ID", example = "tenant_001", required = true)
    private String tenantId;

    /**
     * 训练任务ID
     */
    @Schema(description = "训练任务ID", example = "job_123", required = true)
    private String jobId;

    /**
     * 检查点名称
     */
    @Schema(description = "检查点名称", example = "checkpoint_epoch_2", required = true)
    private String checkpointName;

    /**
     * 轮次
     */
    @Schema(description = "轮次", example = "2", required = true)
    private Integer epoch;

    /**
     * 步数
     */
    @Schema(description = "步数", example = "5000", required = true)
    private Integer step;

    /**
     * 检查点路径
     */
    @Schema(description = "检查点路径", example = "/checkpoints/job_123/epoch_2", required = true)
    private String checkpointPath;

    /**
     * 文件大小
     */
    @Schema(description = "文件大小（字节）", example = "1073741824")
    private Long fileSize;

    /**
     * 损失值
     */
    @Schema(description = "损失值", example = "0.0234")
    private BigDecimal loss;

    /**
     * 学习率
     */
    @Schema(description = "学习率", example = "0.0001")
    private BigDecimal learningRate;

    /**
     * 训练指标（JSON）
     */
    @Schema(description = "训练指标（JSON格式）", example = "{\"loss\":0.0234,\"accuracy\":0.95}")
    private String metrics;

    /**
     * 是否最佳检查点
     */
    @Schema(description = "是否最佳检查点", example = "true")
    private Boolean isBest;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2025-01-01 01:00:00")
    private LocalDateTime createdAt;
}
